<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<script src="js/serverUrl.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<script src="js/mui.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">详情</h1>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded">
				<p>
					申请的实验室：<span id="labName"></span>
				</p>
				<p>
					结果：<span id="result"></span>
				</p>
				<p>
					回复详情：<span id="responseInfo"></span>
				</p>
			</div>
			<div class="mui-content-padded">
				<p id="neiRong">
					
				</p>
			</div>
			
			
			<button id="button" type="button" class="mui-btn" style="float: right; margin-right: 20px;">&nbsp;&nbsp;&nbsp;&nbsp;删除消息&nbsp;&nbsp;&nbsp;&nbsp;</button>
			
		</div>
	</body>
	<script type="text/javascript">
		mui.plusReady(function () {
			// 获取上一页传来的值
		    var cw = plus.webview.currentWebview();
			var msgID = cw.msgID;
			//通过消息列表页传来的msgID，从本地存储中找到这条消息的json
			document.getElementById("labName").innerHTML = JSON.parse(localStorage.getItem("msgID"+msgID)).lab.labName;
			var result = JSON.parse(localStorage.getItem("msgID"+msgID)).result;
			if(result == 1){
				document.getElementById("result").innerHTML = "申请通过";
			}else{
				document.getElementById("result").innerHTML = "申请未通过";
			}
			document.getElementById("neiRong").innerHTML = JSON.parse(localStorage.getItem("msgID"+msgID)).responseInf;
			
			//回复按钮点击事件
			document.getElementById("button").addEventListener("tap", function(){
				var	applyJson = {};
				applyJson.labMessage = JSON.parse(localStorage.getItem("msgID"+msgID));
				applyJson.student = JSON.parse( localStorage.getItem("userInformation") );
				//向服务器发送
				$.ajax({
					//请求方式
					type: 'POST',
					dataType: 'json',
					url: serverUrl + "deleteMessageOfStudent",
					headers: {
						'Content-Type': 'application/json;charset=utf-8'
					},
					data: JSON.stringify(applyJson),
					//请求成功
					success: function(data) {
						if(data == "success"){
							mui.back();
						}
					},
					//请求失败，包含具体的错误信息
					error: function(e) {
						mui.toast("遇到了未知错误！");
					}
				});
			});
			
		});
	</script>
</html>
